<?php
// +----------------------------------------------------------------------
// | WoShiMaiJia Projcet
// +----------------------------------------------------------------------
// | Copyright (c) 2010 http://woshimaijia.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: xinqiyang <517577550@qq.com>
// +----------------------------------------------------------------------
/**
 * BrandModel
 * @author xinqiyang
 * @date   2010-7-5
 *
 */
class BrandModel extends MetaModel
{


	protected $_validate  = array(
	array ('title','require','品牌名称不能为空',1,'',1),
	array('title','','品牌已经发布过了,谢谢啦',1,'unique',1),
	array ('enname','require','品牌英文名称不能为空',1,'',1),
	array('enname','','品牌英文名称已经被使用了',1,'unique',1),
	array ('desc','require','描述不能为空',1,'',1),
	array ('siteurl','url','网址不能为空或者格式不正确,例如http://www.paipai.com/',1,'',1),
	array('siteurl','','网址已经发布过了,谢谢啦',1,'unique',1),
	array ('tags','require','标签不能为空',1,'',1),
		
	);


	protected $_auto = array(
	array ('status','1'),
	array ('user_id','userID',1,'function'),
		

	);
	
	public function getBrands($arr)
	{
		return  $this->query("select sz_brand.id as bid,sz_brand.title,sz_brand.siteurl,sz_brand.user_id,sz_brand.tags,sz_brand.supportnum,sz_brand.buynum,sz_brand.desc,sz_user.cnname,sz_brand.user_id as uid,sz_image.id,sz_image.url,sz_image.model,sz_image.filename from sz_brand,sz_image,sz_user where sz_brand.image_id=sz_image.id and sz_brand.user_id = sz_user.id and sz_brand.id in ".strin($arr));
		
	}
	
	public function newgetBrands($arr)
	{
		return  $this->query("select sz_brand.id as bid,sz_brand.title,sz_brand.siteurl,sz_brand.user_id,sz_brand.tags,sz_brand.supportnum,sz_brand.buynum,sz_brand.desc,sz_user.cnname,sz_brand.user_id as uid,sz_image.id,sz_image.url,sz_image.model,sz_image.filename from sz_brand,sz_image,sz_user where sz_brand.image_id=sz_image.id and sz_brand.user_id = sz_user.id and sz_brand.id in ".$arr.' order by rand()');
		
	}
}
?>